package com.spic.business.ioc.controller;

import com.spic.business.ioc.domain.IocPmTwoPointFive;
import com.spic.business.ioc.service.IIocPmTwoPointFiveService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * PM2.5达标情况IOCController
 *
 * @author spic
 * @date 2022-04-14
 */
@RestController
@RequestMapping("/ioc/pm_two_point_five")
public class IocPmTwoPointFiveController extends BaseController
{
    @Autowired
    private IIocPmTwoPointFiveService iocPmTwoPointFiveService;

    /**
     * 查询PM2.5达标情况IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:pm_two_point_five:list")
    @GetMapping("/list")
    public TableDataInfo list(IocPmTwoPointFive iocPmTwoPointFive)
    {
        startPage();
        List<IocPmTwoPointFive> list = iocPmTwoPointFiveService.selectIocPmTwoPointFiveList(iocPmTwoPointFive);
        return getDataTable(list);
    }

    /**
     * 导出PM2.5达标情况IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:pm_two_point_five:export")
//    @Log(title = "PM2.5达标情况IOC", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IocPmTwoPointFive iocPmTwoPointFive) throws IOException
    {
        List<IocPmTwoPointFive> list = iocPmTwoPointFiveService.selectIocPmTwoPointFiveList(iocPmTwoPointFive);
        ExcelUtil<IocPmTwoPointFive> util = new ExcelUtil<IocPmTwoPointFive>(IocPmTwoPointFive.class);
        util.exportExcel(response, list, "PM2.5达标情况IOC数据");
    }

    /**
     * 获取PM2.5达标情况IOC详细信息
     */
//    @PreAuthorize(hasPermi = "ioc:pm_two_point_five:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(iocPmTwoPointFiveService.selectIocPmTwoPointFiveById(id));
    }

    /**
     * 新增PM2.5达标情况IOC
     */
//    @PreAuthorize(hasPermi = "ioc:pm_two_point_five:add")
//    @Log(title = "PM2.5达标情况IOC", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IocPmTwoPointFive iocPmTwoPointFive)
    {
        return toAjax(iocPmTwoPointFiveService.insertIocPmTwoPointFive(iocPmTwoPointFive));
    }

    /**
     * 修改PM2.5达标情况IOC
     */
//    @PreAuthorize(hasPermi = "ioc:pm_two_point_five:edit")
//    @Log(title = "PM2.5达标情况IOC", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IocPmTwoPointFive iocPmTwoPointFive)
    {
        return toAjax(iocPmTwoPointFiveService.updateIocPmTwoPointFive(iocPmTwoPointFive));
    }

    /**
     * 删除PM2.5达标情况IOC
     */
//    @PreAuthorize(hasPermi = "ioc:pm_two_point_five:remove")
//    @Log(title = "PM2.5达标情况IOC", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(iocPmTwoPointFiveService.deleteIocPmTwoPointFiveByIds(ids));
    }
}
